<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户角色编辑</title>
<script type="text/javascript" src="<c:url value='/admin/js/util/jquery-1.8.1.min.js' />" ></script>
<script type="text/javascript" src="<c:url value='/admin/js/util/common.js' />" ></script>
<script type="text/javascript" src="<c:url value='/admin/js/util/validate.js' />" ></script>
<link href="<c:url value='/admin/css/general.css'/>" rel="stylesheet" type="text/css" />
<script language="javascript">
function addCustomers(o,a,b){ 
	var t=document.getElementById(o).getElementsByTagName("tr"); 
	for(var i=0;i<t.length;i++){ 
		t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b; 
		t[i].onmouseout=function(){ 
		if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b; 
		};
	} 
}

function submitForm() {
		var checkedRoleIds = getCheckBoxValue("ur_checkbox").toString();
		$("#checkedRoleIds").val(checkedRoleIds);
		$("#mainForm").attr("action", "<c:url value='/admin/adminUserAction!editUserRoleExc.do' />");
		$("#mainForm").submit();
}

function returnMain() {
	document.location.href = "<c:url value='/admin/adminUserAction!list.do' />";
}
</script> 
</head>
<body>
<form id="mainForm" action="" method="post">
	<input type="hidden" name="checkedRoleIds" id="checkedRoleIds" value=""/>
	<input type="hidden" name="adminUser.id" value="${ adminUser.id }"/>
	
	<div class="tableTitle">编辑用户角色</div>
	<table width="100%" cellspacing="1" id="addCustomers">
	  <tr><th>注：带<b>*</b>号的为必填项</th></tr>
	  <tr><td width="50%"><span>用户名称：</span><input name="" type="text" disabled="disabled" value="${ adminUser.realName }"/></td></tr>
	  <tr><td><span>角色：</span><input name="c_checkbox" type="checkbox" value="" class="theOne" onclick="changeAllCheckBox('c_checkbox','ur_checkbox')"/></td></tr>
	  <tr><td>
	      <ul>
	      	<c:forEach items="${ allRoleList }" var="item" varStatus="status">
	      		<li><input name="ur_checkbox" type="checkbox" value="${ item.id }"/>${ item.name }</li>
	      	</c:forEach>
	      </ul>
	  </td></tr>
	  <tr><td><a href="javascript:submitForm();">保存</a><a href="javascript:returnMain();">返回</a></td></tr></table>
</form>

<script language="javascript">
//addCustomers("表格名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景"); 
addCustomers("addCustomers","#fff","#F6F6F6");

$(document).ready(function() {
	var myRoleIds = '${ requestScope.myRoleIds }';
	var myRoleIdArr = {};
	if (myRoleIds) {
		myRoleIdArr = myRoleIds.split(",");
	}
	for (var i = 0; i < myRoleIdArr.length; i++) {
		$(":checkbox[name='ur_checkbox'][value='" + myRoleIdArr[i] + "']").attr("checked", true);
	}
});
</script> 
</body>
</html>
